home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / tcoop.arc / TCOOP2.ARC / DIALOGUE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-26  |  2.1 KB  |  92 lines

  1. // dialogue.cpp: Dialog box methods
  2.  
  3. #include <string.h>
  4. #include "dialogue.h"
  5.  
  6. // -------------------- CmndButton methods --------------------
  7.  
  8. CmndButton::CmndButton(char *T, ColorPak &Cp)
  9. : Wso(0x00, 0x00, Cp)
  10. {
  11.   strncpy(Text, T, 6);
  12.   Text[6] = 0;  // Ensure null termination
  13.   SetSize(8,1); // Command buttons are always 8 characters long 
  14.   SelectStat = False;
  15. }
  16.  
  17. void CmndButton::Draw(void)
  18. {
  19.   Wso::Draw();
  20.   Panel->HzWrtB(0, 0, "<      >");
  21.   Panel->HzWrtB((7-strlen(Text)) / 2 + 1, 0, Text);
  22. }
  23.  
  24. void CmndButton::Prompt(void)
  25. {
  26.   Wso::Prompt();
  27.   Panel->FillB(0,0,Panel->Interior->Wd,1,Panel->Colors.Pc,1);
  28. }
  29.  
  30. void CmndButton::UnPrompt(void)
  31. {
  32.   if (Active) {
  33.     Panel->FillB(0,0,Panel->Interior->Wd,1,Panel->Colors.Wc,1);
  34.     Wso::UnPrompt();
  35.   }
  36. }
  37.  
  38. void CmndButton::Activate(MsgPkt &M)
  39. {
  40.   Base->SwitchFocus(M);
  41.   M.RtnCode = Close; // Effectively tells base to close 
  42. }
  43.  
  44. // --------------------- DlgBox Methods -------------------
  45.  
  46. void DlgBox::SetSize(int W, int H)
  47. {
  48.   Wso::SetSize(W, H+2);
  49. }
  50.  
  51. void DlgBox::Draw(void)
  52. {
  53.   int Y;
  54.  
  55.   Mouse.Hide();
  56.   Wso::Draw();
  57.   // Draw rule two lines from the bottom 
  58.   Y = Panel->Frame->Ht - 3;
  59.   Panel->Frame->Fill(0, Y, 1, 1, 0xC3, Panel->Colors.Bc);
  60.   Panel->Frame->Fill(1, Y, Panel->Frame->Wd-2, 1,
  61.                      0xC4, Panel->Colors.Bc);
  62.   Panel->Frame->Fill(Panel->Frame->Wd-1, Y, 1, 1,
  63.                      0xB4, Panel->Colors.Bc);
  64.   Mouse.Show();
  65. }
  66.  
  67. // ------------------ MsgBox Methods ------------------------- 
  68.  
  69. MsgBox::MsgBox(char *T, int Ba, int Fa, ColorPak &Cp)
  70. : DlgBox(Ba, Fa, Cp)
  71. {
  72.   strncpy(Text, T, 39); Text[39] = 0; // Ensure null termination
  73.   SetSize(Panel->TextWidth(T)+2, Panel->TextHeight(3));
  74.   OKButton = new CmndButton("OK", Cp);
  75. }
  76.  
  77. void MsgBox::Open(Iso *B, int X, int Y)
  78. {
  79.   DlgBox::Open(B, X, Y);
  80.   OKButton->Open(this, 
  81.                  Panel->Frame->Wd - OKButton->Panel->Frame->Wd-4,
  82.                  Panel->Frame->Ht-2);
  83. }
  84.  
  85. void MsgBox::Draw(void)
  86. {
  87.   DlgBox::Draw();
  88.   // Write message to dialog box 
  89.   Panel->HzWrt(1, 1, Text, 0);
  90. }
  91.  
  92.